<template>
  <div class="pay-list">
    <div class="card" v-for="(order, i) in orderlist" :key="i">
      <div class="card-header">
        <span class="title">{{ order.order_create_time }}</span>
        <span>
          <span v-if="order.is_pay">已支付</span><span v-else>未支付</span> |
          <span v-if="order.is_cancel">已取消</span>
          <span v-else @click="cancel(i)" class="cancel">取消订单</span>
        </span>
      </div>
      <div class="card-content" @click="show(i)">
        <div class="card-content-inner">
          <div class="cover" v-for="item in order.goods_list" :key="item.id">
            <div class="img-con">
              <img :src="item.goods_small_logo" />
            </div>
            <div class="img-tag">x{{ item.num }}</div>
          </div>
        </div>
      </div>
      <p>
        实付金额：<span>¥{{ order.order_price }}</span>
      </p>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";

export default {
  computed: {
    ...mapGetters("order", { orderlist: "getOrderlist" }),
  },
  methods: {
    show(i) {
      this.$router.push({ name: "order_show", params: { i: i } });
    },
    cancel(i) {
      this.orderlist.splice(i, 1);
    },
  },
};
</script>

<style lang="scss" scoped>
.cancel {
  z-index: 999;
}
.card {
  margin: 15px;
  padding: 15px;
  border-radius: 15px;
  box-shadow: 0 0.1rem 0.25rem #ccc;
}
.pay-list p {
  padding: 0 10px;
  text-align: right;
  span {
    color: #151515;
  }
}
.card-header {
  color: #999;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  span.title {
    font-size: 13px;
    color: #888;
  }
}
.card-content-inner {
  .cover {
    position: relative;
    width: 70px;
    height: 70px;
    display: inline-block;
    margin-right: 10px;
    .img-con {
      width: 100%;
      height: 100%;
      margin-right: 10px;
      border-radius: 2px;
      position: relative;
      img {
        width: 100%;
        height: 100%;
        border-radius: 2px;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate3d(-50%, -50%, 0);
      }
    }
    .img-tag {
      position: absolute;
      opacity: 0.5;
      background: #000;
      color: #fff;
      text-align: center;
      font-size: 12px;
      right: 0;
      bottom: 0;
      padding: 0 5px;
      border-radius: 2px 0;
    }
  }
}
</style>
